package com.example.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.example.dto.PayRequest;
import com.example.dto.PayResponse;
import com.example.po.SysPay;
import com.example.po.SysUser;
import com.lly835.bestpay.model.RefundResponse;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public interface SysPayService extends IService<SysPay> {

    /****
     * 发起支付
     * @param sysPay
     * @return
     */
    public com.lly835.bestpay.model.PayResponse apply(SysPay sysPay);

    /***
     * 发起退款
     * @param orderId
     * @return
     * @throws Exception
     */
    public RefundResponse refund(String orderId) throws Exception;


    /***
     * 支付通知
     * @param notifyData
     * @return
     * @throws Exception
     */
    public String notify(String notifyData);


    /****
     * 设置支付状态
     * @param orderId
     */
    public void setPayed(String orderId);


    /****
     * 根据订单号查询订单
     * @param orderId
     * @return
     */
    public SysPay getSysPay(String orderId);


    /****
     * 查询待发送的数据
     * @return
     */
    public List<SysPay> getSysPayList();


    /****
     *
     * @param payRequest
     * @param httpServletRequest
     * @return
     * @throws Exception
     */
    public PayResponse apply(PayRequest payRequest, HttpServletRequest httpServletRequest) throws Exception;


    /****
     * 解密参数信息
     * @param payRequest
     * @param sysUser
     * @return
     * @throws Exception
     */
    public PayRequest decryptRequest(PayRequest payRequest, SysUser sysUser) throws Exception;


    /****
     * 构建订单信息
     * @param payRequest
     * @return
     */
    public SysPay buildOrder(PayRequest payRequest, SysUser sysUser) throws Exception;


    /****
     * 构建加密返回内容
     * @param payResponse
     * @return
     * @throws Exception
     */
    public PayResponse buildResponse(SysUser sysUser, SysPay sysPay, com.lly835.bestpay.model.PayResponse payResponse) throws Exception;
}
